<template>
	<view class="userpage" :style="'padding-top:'+ (statusBarHeight+80) +'rpx;'">
		<view class="user_nav" v-if="isshowtop" :style="'padding-top:'+ (statusBarHeight+80) +'rpx'"></view>
		<view class="userpage_head">
			<view class="userpage_head_set" @click="jump('/pages/mine/set/set')">
				<view class="menu_u_item_icon1" :style="{backgroundImage:'url('+photo_cdn1+'zpupload/20240105/f50486c20c40e79857.png)'}"></view>
			</view>
			
			<view class="user_info_card flex ali-c jus-b">
				<view class="flex ali-c" @click="jump('/pages/mine/editinfo/editinfo')">
					<image class="uutx" v-if="userInfo.avatar" :src="photo_cdn1+userInfo.avatar" mode=""></image>
					<!-- 0：女 1：男 -->
					<image class="uutx" v-else-if="userInfo.gender==1" :src="photo_cdn1+'/zpupload/static/tablet/boy_alive.png'" mode=""></image>
					<image class="uutx" v-else :src="photo_cdn1+'/zpupload/static/tablet/girl_alive.png'" mode=""></image>
					<view class="uu_nikeinfo">
						<view class="nicknames">{{userInfo.nickname}}</view>
						<view v-if="userInfo.addr_name" class="uu_address">{{userInfo.addr_name.province}} {{userInfo.addr_name.city}} {{userInfo.addr_name.county}}</view>
					</view>
				</view> 
				<view>
					<view @click="jump('/pages/mine/business_card/business_card')" class="qricon" :style="{backgroundImage:'url('+photo_cdn1+'zpupload/20240105/a9e3178a0d6a889529.png)'}"></view>
					<view class="u_minpian flexc" @click="jump('/pages/mine/editinfo/editinfo')">
						<!-- <image class="mpicon" src="/s1tatic/user/mpicon.png" mode=""></image> -->
						<image class="mpicon"  :src="photo_cdn1+'zpupload/gif/1.gif'" mode=""></image>
						<view class="umptext">编辑资料</view>
					</view>
				</view>
				
			</view>
			<!-- <view class="user_info_totals flex jus-b ali-c">
				<view class="u_totals_data flex ali-c jus-a flex1">
					<view  class="u_totals_item" @click="jump('/pagesim/address-list/address-list')" >
						<view class="u_totals_val">{{FriendsNum?FriendsNum:0}}</view>
						<view class="u_totals_text">好友</view>
					</view>
				

					<view class="u_totals_item"  @click="jump('/pagesim/address-list/group-chat')" >
						<view class="u_totals_val">{{GroupNum?GroupNum:0}}</view>
						<view class="u_totals_text">群组</view>
					</view>
					

					<view class="u_totals_item" >
						<view class="u_totals_val">{{userInfo.win_shares?userInfo.win_shares:0}}</view>
						<view class="u_totals_text">贡献值</view>
					</view>
					<view class="user_editor">
					</view>
				</view>									
			</view> -->
		</view>

		<!-- <view class="invitefind flex ali-c">
			<image class="jinbi" src="/s1tatic/user/jinbi.png" mode=""></image>
			<view class="findbytext">
				<view class="maxtitles">邀请同源眷属有好礼</view>
				<view class="subtitles">累计邀请拿收益</view>
			</view>
			<view class="toinvites flex ali-c">
				<view class="invite_tts">邀请</view>
				<image class="jtimg" src="/s1tatic/user/jtimg.png" mode=""></image>
			</view>
			@click='jump("/pages/mine/jifen/jifen")'
		</view> -->
		<view style="padding: 0 20rpx;" >
			<view class="genetic_main" :style="{backgroundImage:'url('+photo_cdn1+'zpupload/20240105/945772397c07f8cbe3.png)'}">
				<view>
					<view class="genetic_buy">基因检测</view>
					<view class="genetic_clear">解锁基因中的家族历史</view>
				</view>
				<!-- <view class="genetic_btn">立即购买</view> -->
			</view>
		</view>
		
		<view class="flex flex-wrap menu_user_list">		
			<!-- <navigator v-if="userInfo.is_shaikh==1" url="/pages/management/home/home" hover-class="none" class="menu_u_item"> -->
				<!-- <view class="menu_u_item" v-if="userInfo.is_shaikh==1" @click="jump('/pages/management/home/home')">
					<image class="menu_u_item_icon" src="/s1tatic/user/management.png" mode="heightFix"></image>
					<view class="menu_u_item_name">管理端</view>
				</view> -->
				<!-- <view class="menu_u_item" v-for="(item,index) in itemList.list" :key="index"  @click="jump(item.url)" v-if="item.applepay || item.is_shaikh">
					<view >
						<image class="menu_u_item_icon" :src="photo_cdn1+item.img" mode="heightFix"></image>
						<view class="menu_u_item_name">{{item.title}}</view>
					</view>
				</view> -->
				<!-- <navigator url="/pagesim/address-list/address-list" hover-class="none" class="menu_u_item"> -->
				
				
				<view class="menu_u_item" v-for="(item,index) in headList" :key="index"  @click="jump(item.url)" >
					<view :class="item.class" :style="{backgroundImage:'url('+photo_cdn1+ item.img +')'}"></view>
					<view class="menu_u_item_name">{{item.title}}</view>
					<view :class="item.color">{{item.value}}</view>
				</view>	 
				
				<!-- <view class="menu_u_item" @click="jump('/pagesim/address-list/address-list')" >
					<view class="menu_u_item_icon" :style="{backgroundImage:'url('+photo_cdn1+'zpupload/20240105/4bafb01c47a4751646.png)'}"></view>
					<view class="menu_u_item_name">我的人脉</view>
					<view class="menu_u_item_num">{{FriendsNum?FriendsNum:0}}</view>
				</view>	 -->	
				<!-- </navigator> -->
				<!-- <view class="menu_u_item">
					<view class="menu_u_item_icon1" :style="{backgroundImage:'url('+photo_cdn1+'zpupload/20240105/c2084022b7e094e6b7.png)'}"></view>
					<view class="menu_u_item_name">贡献值</view>
					<view class="menu_u_item_num">{{userInfo.win_shares?userInfo.win_shares:0}}</view>
				</view> -->
				<!-- <navigator url="/pages/mine/wallet/wallet" hover-class="none" class="menu_u_item"> -->
				<!-- <view class="menu_u_item" @click="jump('/pages/mine/wallet/wallet')" >
					<view class="menu_u_item_icon1" :style="{backgroundImage:'url('+photo_cdn1+'zpupload/20240105/6946dbc3daf186a240.png)'}"></view>
					<view class="menu_u_item_name">钱包</view>
					<view class="menu_u_item_num">***</view>
				</view>	 -->	
				<!-- </navigator> -->
				<!-- <navigator hover-class="none" class="menu_u_item"> -->
				<!-- <view class="menu_u_item" >
					<view class="menu_u_item_icon1" :style="{backgroundImage:'url('+photo_cdn1+'zpupload/20240105/001bd544e2011bc831.png)'}"></view>
					<view class="menu_u_item_name">期权</view>
					<view class="menu_u_item_num">0</view>
				</view>	 -->
				<!-- </navigator> -->
				
			<!-- </navigator>
			
		<!-- 	<navigator url="/pages/zupu/myzupu/myzupu" hover-class="none" class="menu_u_item menu_u_item_myzupu">
				<view>
					<image class="menu_u_item_icon" src="/s1tatic/user/wdzp.png" mode="heightFix"></image>
					<view class="menu_u_item_name">我的族谱</view>
				</view>
				
			</navigator> -->
			
			<!-- <view class="menu_u_item">
				<image class="menu_u_item_icon" src="/s1tatic/user/xungeng.png" mode="heightFix"></image>
				<view class="menu_u_item_name">我的寻根</view>
			</view> -->

			<!-- <navigator v-if="apple_isdebug" url="/pages/mine/wallet/wallet" hover-class="none" class="menu_u_item">
				<image class="menu_u_item_icon" src="/s1tatic/user/qbicon.png" mode="heightFix"></image>
				<view class="menu_u_item_name">钱包</view>
			</navigator>
			
			<navigator  v-if="apple_isdebug"  url="/pages/zupu/my_order/my_order" hover-class="none" class="menu_u_item">
				<image class="menu_u_item_icon" src="/s1tatic/user/order.png" mode="heightFix"></image>
				<view class="menu_u_item_name">我的订单</view>
			</navigator> -->
			
			
			<!-- <view class="menu_u_item">
				<image class="menu_u_item_icon" src="/s1tatic/user/listicon.png" mode="heightFix"></image>
				<view class="menu_u_item_name">邀请列表</view>
			</view> -->
			
			<!-- <view class="menu_u_item">
				<image class="menu_u_item_icon" src="/s1tatic/user/cjwt.png" mode="heightFix"></image>
				<view class="menu_u_item_name">常见问题</view>
			</view> -->
			
			
			<!-- <navigator url="/pages/zupu/collectzhuzhi/collectzhuzhi" hover-class="none" class="menu_u_item">
				<image class="menu_u_item_icon" src="/s1tatic/user/scicon.png" mode="heightFix"></image>
				<view class="menu_u_item_name">文章收藏</view>
			</navigator>
			
			<navigator v-if="apple_isdebug" url="/pages/mine/banklist/banklist" hover-class="none" class="menu_u_item">
				<image class="menu_u_item_icon" src="/s1tatic/user/bank.png" mode="heightFix"></image>
				<view class="menu_u_item_name">我的银行卡</view>
			</navigator> -->
			
			<!-- v-if="userInfo.is_shaikh" -->
		<!-- 	<navigator url="/pages/zupu/push_article/push_article" hover-class="none" class="menu_u_item">
				<image class="menu_u_item_icon" src="/s1tatic/user/write.png" mode="heightFix"></image>
				<view class="menu_u_item_name">发布族志</view>
			</navigator>

			<navigator url="/pages/zupu/my_article/my_article" hover-class="none" class="menu_u_item">
				<image class="menu_u_item_icon" src="/s1tatic/user/listicon.png" mode="heightFix"></image>
				<view class="menu_u_item_name">我的文章</view>
			</navigator> -->


			<!-- <view class="menu_u_item">
				<image class="menu_u_item_icon" src="/s1tatic/user/qingdan.png" mode="heightFix"></image>
				<view class="menu_u_item_name">操作说明</view>
			</view> -->


			<!-- <navigator url="/pagesim/center/to-do" hover-class="none" class="menu_u_item">
				<image class="menu_u_item_icon" src="/s1tatic/user/daiban.png" mode="heightFix"></image>
				<view class="menu_u_item_name">我的待办</view>
			</navigator> -->

			<!-- <navigator url="/pagesim/center/collection" hover-class="none" class="menu_u_item">
				<image class="menu_u_item_icon" src="/s1tatic/user/enshrine.png" mode="heightFix"></image>
				<view class="menu_u_item_name">聊天收藏</view>
			</navigator> -->
			
			<!-- <navigator url="/pages/findpu/findpu" hover-class="none" class="menu_u_item">
				<image class="menu_u_item_icon" src="/s1tatic/user/enshrine.png" mode="heightFix"></image>
				<view class="menu_u_item_name">寻谱</view>
			</navigator> -->

		<!-- 	<navigator url="/pagesim/center/general-settings" hover-class="none" class="menu_u_item">
				<image class="menu_u_item_icon" src="/s1tatic/user/site.png" mode="heightFix"></image>
				<view class="menu_u_item_name">聊天设置</view>
			</navigator> -->

		<!-- 	<navigator url="/pagesim/center/privacy-settings" hover-class="none" class="menu_u_item">
				<image class="menu_u_item_icon" src="/s1tatic/user/yinsi.png" mode="heightFix"></image>
				<view class="menu_u_item_name">隐私设置</view>
			</navigator> -->

			<!-- <navigator url="/pagesim/center/report?title=反馈" hover-class="none" class="menu_u_item">
				<image class="menu_u_item_icon" src="/s1tatic/user/fankui.png" mode="heightFix"></image>
				<view class="menu_u_item_name">反馈问题</view>
			</navigator> -->
			
			
		<!-- 	<navigator hover-class="none" url="/pages/mine/about/about" class="menu_u_item">
				<image class="menu_u_item_icon" src="/s1tatic/user/about.png" mode="heightFix"></image>
				<view class="menu_u_item_name">关于我们</view>
			</navigator>
			<navigator hover-class="none" url="/pages/mine/set/set" class="menu_u_item">
				<image class="menu_u_item_icon" src="/s1tatic/user/site.png" mode="heightFix"></image>
				<view class="menu_u_item_name">系统设置</view>
			</navigator> -->
			<!-- <navigator url="/pages/mine/set/set" hover-class="none" class="site_icon">
				<image class="siteicon" src="/s1tatic/user/siteicon.png" mode=""></image>
			</navigator> -->
		</view>
		
		
		
		<view class="menu_user_nav" v-for="(item,index) in itemList" :key="index"   v-if="item.applepay" @click="jump(item.url)">
			<view class="flex ali-c">
				<view class="nav_img_box" :style="{backgroundColor : item.color}">
					<view class="user_nav_img" :style="{backgroundImage:'url('+photo_cdn1+item.img+')'}"></view>
				</view>			
				<view class="user_nav_text">{{item.title}}</view>
			</view>
			<view style="font-size: 32rpx;color: #A3A3A3;">></view>
		</view>
		
		
<!-- 		<view class="menu_user_nav" @click="jump('/pages/zupu/myzupu/myzupu')">
			<view class="flex ali-c">
				<view class="nav_img_box" style="background-color: #DF7133;">
					<view class="user_nav_img" :style="{backgroundImage:'url('+photo_cdn1+'zpupload/20240105/0241c0192666831834.png)'}"></view>
				</view>	
				<view class="user_nav_text">我的族谱</view>
			</view>
			<view style="font-size: 32rpx;color: #A3A3A3;">></view>
		</view>
		<view class="menu_user_nav" v-if="userInfo.is_shaikh==1" @click="jump('/pages/management/home/home')">
			<view class="flex ali-c">
				<view class="nav_img_box" style="background-color: #B13B3B;">
					<view class="user_nav_img" :style="{backgroundImage:'url('+photo_cdn1+'zpupload/20240105/8f796bfd5aeec49e7b.png)'}"></view>
				</view>			
				<view class="user_nav_text">管理端</view>
			</view>
			<view style="font-size: 32rpx;color: #A3A3A3;">></view>
		</view>
		
		<view class="menu_user_nav" v-if="userInfo.is_shaikh==1" @click="jump('/pages/management/daili/daili')">
			<view class="flex ali-c">
				<view class="nav_img_box" style="background-color: #B13B3B;">
					<view class="user_nav_img" :style="{backgroundImage:'url('+photo_cdn1+'zpupload/static/img/daili1.png)'}"></view>
				</view>			
				<view class="user_nav_text">代理端</view>
			</view>
			<view style="font-size: 32rpx;color: #A3A3A3;">></view>
		</view> -->
		
		<view class="groom_nav">
			<view class="nav_item" :class="{active:nav_index==item.id}" v-for="(item,index) in navList.list" :key="item.id" @tap="toggle(item)">
				{{item.name}}
			</view>
		</view>
		<view class="user_bottom">
			<view class="groom_list">
				<view class="groom_list_all">
					
					<scroll-view v-if="friend_list.length"  scroll-top="0" scroll-y="true" class="scroll-Y" style="width: 100%;" @scrolltolower="upper"   :style="{height: WinHeight +'px'}"  >
						<view class="groom_list_item" v-for="(item,index) in friend_list" :key="index" @tap="toCall(item)">
							<view class="flex ali-c">
								<image v-if="item.avatar" class="people_img" :src="item.avatar"></image>
								<image v-else class="people_img" :src="photo_cdn1+'/zpupload/static/user/normal.png'"></image>
								<view style="margin-left: 20rpx;">
									<view class="people_name">{{item.nickname}}</view>
									<!-- <view class="people_address">江西省 南昌市 南昌县</view> -->
								</view>
							</view>
							<!-- 加好友 -->
							<view class="add_people">
								<view class="add_people_img" :style="{backgroundImage:'url('+photo_cdn1+'zpupload/20240105/9cba96d90f7b527cb8.png)'}"></view>
								<view>{{item.rntitle }}</view>
							</view>
						</view>
					</scroll-view>	
					
					
					
				</view>				
			</view>
			
			<empty v-if="!friend_list.length"></empty>
		</view>
		<ypickerview ref="ypickerview" @changpicker="changpicker"></ypickerview>
		<!-- 五级联动选择 -->
		<xkyguidestep :step="step" ref="xkyguidestep"></xkyguidestep>
		<!-- 引导操作 -->
		<q-tabbar :active="4" :count="[0,0,0,0,0]"></q-tabbar>
		<!-- 登录提醒 -->
		<login :hidden="isshowlogin" @close="closefun" @loginsucc="loginsucc"></login>
	</view>
</template>

<script>
	import { getUserinfo,authorWechat } from "@/utils/api/api.js";
	import {getRandomFriends,getPagesUser} from "@/utils/api/user.js"
	import config from "@/utils/config.js";
	let {staticurl,photo_cdn1} = config.baseUrl;
	import {lk_reverse} from "@/utils/libs/luokuangmap.js";
	import ypickerview from "@/components/ypickerview/ypickerview.vue";
	import debug from "@/utils/debug.js";
	let {apple_isdebug} = debug
	const apple = debug.apple_isdebug;
	import xkyguidestep from "@/components/xkyguidestep/xkyguidestep.vue";
	import {updateUserinfo} from "@/utils/api/user.js"
	export default {
		components:{
			ypickerview,
			xkyguidestep,
		},
		data() {
			return {
				apple_isdebug:apple,//苹果开关
				FriendsNum:0,
				GroupNum:0,
				isshowtop: false,
				//oss根路径url
				staticurl,
				photo_cdn1,
				//登录提醒
				isshowlogin: false,
				statusBarHeight: 0, //通知栏高度
				userInfo: {},
				nav_index:1,
				friend_list:[],
				friends:{},
				navList:[],
				province_id:"",
				county_id:"",
				area_obj:{},
				step:{},
				headList:null,
				itemList:null,
				// itemList:[
				// 	{
				// 		title:'我的族谱',
				// 		img:'zpupload/20240105/0241c0192666831834.png',
				// 		url:'/pages/zupu/myzupu/myzupu',
				// 		color:'#DF7133',
				// 		applepay:true,
				// 	},{
				// 		title:'管理端',
				// 		img:'zpupload/20240105/8f796bfd5aeec49e7b.png',
				// 		url:'/pages/management/home/home',
				// 		color:'#B13B3B',
				// 		applepay:true,
				// 	},{
				// 		title:'代理端',
				// 		img:'zpupload/static/img/daili1.png',
				// 		url:'/pages/management/daili/daili',
				// 		color:'#B13B3B',
				// 		applepay:true,
				// 	},
					
				// ],
				WinHeight:500,
			}
		},
		filters:{
			// | buddy
			buddy(val){
				let rntitle = "";
				console.info("this.friends",val);
				if(this.friends){
					for(var key in this.friends){
						for(var i=0;i<this.friends[key].lengthh;i++){
							if(val==this.friends[key][i].friend_id){
								rntitle = '发消息';
								break;
							}else{
								rntitle =  '加好友'
							}
						}
					}
				}
				return rntitle;
			}
		},
		onLoad() {
			//获取设备高度
			this.WinHeight = uni.getWindowInfo().windowHeight - 450 ;
			this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight * 2;
			if (uni.getUserProfile) {
				this.canIUseGetUserProfile = true
			}
			this.getRandomFriendsfun();
			this.loginAuct();
		},
		async onShow() {
			let token = uni.getStorageSync("token")
			if (!token) {
				// #ifdef MP-WEIXIN
				setTimeout(() => {
					this.isshowlogin = true;
				}, 1500)
				// #endif
			} else {
				await this.getUserinfofun();								
			}
			//获取好友成员数量
			this.ws.pageFun(this.pageDataLoad, this);
			this.onPagesUser();
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
			if (e.scrollTop > 100) {
				this.isshowtop = true;
			} else {
				this.isshowtop = false;
			}
		},
		onPullDownRefresh() {
			this.getUserinfofun();
			this.ws.pageFun(this.pageDataLoad(true), this);
			setTimeout(() => {
				uni.stopPullDownRefresh(); //结束下拉刷新
			}, 3000)
			console.log(this.friends,'222222')
		},
		methods: {
			//无限加载内容
			upper: function(e) {
				// console.log(e)
				this.getRandomFriendsfun();
			},
			//初始化页面
			onPagesUser(){
				getPagesUser().then(res=>{
					console.log(res)
					if(res.code == 1){
						this.step = res.data.list.step
						this.navList = res.data.list.navList;
						this.itemList = res.data.list.itemList1;
						this.headList = res.data.list.headList;
					}
				})
			},
			loginAuct(){
				let token = uni.getStorageSync("token")
				if (!token) {
					this.isshowlogin = true;//显示去登录
					return false;
				}
				this.isshowlogin = false;
				return true;
			},	
			changpicker(data){
				console.info('data',data);
				this.area_obj = {
					province_id:data.checkArr[0],
					city_id:data.checkArr[1],
					area_id:data.checkArr[2],
					town_id:data.checkArr[3],
					village_id:data.checkArr[4],
				};
				this.page = 0;
				// this.isshowall = false;
				this.friend_list = [];
				
				//修改信息
				updateUserinfo({
					...thisarea_obj,
				}).then(res=>{
					
				})
				
				
				this.getRandomFriendsfun();
			},
			//获取好友数量 和群数量
			pageDataLoad: function (refresh = false) {								
				this.ws.send({
					c: 'User',
					a: 'loadContact',
					data: {
						'method': 'all-group-chat',
						'refresh': refresh
					}
				})
				
				this.ws.send({
					c: 'User',
					a: 'loadContact',
					data: {
						'method': 'all-friend',
						'refresh': refresh
					}
				})
			},
			//关闭授权登录弹窗
			closefun() {
				this.isshowlogin = false;
			},
			//登录完成
			loginsucc() {

			},
			//跳转
			jump(e){
				if(this.loginAuct()){
					if(e){
						uni.navigateTo({
						url: e
					});
					}
					
				}
			},
			//切换
			toggle(item){
				this.friend_list = [];
				if(this.loginAuct()){
					console.log(item)
					if(this.nav_index==item.id){
						return false;
					}
					this.nav_index = item.id
					
					this.friend_list = [];
					// this.getRandomFriendsfun();
					if(this.nav_index==1){
						this.getRandomFriendsfun();
					}
					if(this.nav_index==2){
						if(this.userInfo.surname_id){
							this.getRandomFriendsfun();
						}else{
							this.$showModal({
							    title:'温馨提示',
							    concent:'您还未填写您的姓氏',
							    confirmVal:'去填写',
								// delCancel:true,
							    cancelVal:'拒绝',
							}).then(res=>{
								uni.navigateTo({
									url:'/pages/mine/editinfo/editinfo'
								})
							}).catch(()=>{
							   //拒绝了~~  
							})
						}
					}
					if(this.nav_index==3){
						if(this.area_obj.town_id){
							this.getRandomFriendsfun();
						}else{
							this.$showModal({
							    title:'温馨提示',
							    concent:'您还未填写您的所在区域',
							    confirmVal:'去填写',
								// delCancel:true,
							    cancelVal:'拒绝',
							}).then(res=>{
								this.$refs.ypickerview.show();//弹窗框框
								// uni.navigateTo({
								// 	url:'/pages/mine/editinfo/editinfo'
								// })
							}).catch(()=>{
							   //拒绝了~~		   
							})
						}
					}
					if(this.nav_index==4){
						if(this.userInfo.educational){
							this.getRandomFriendsfun();
						}else{
							this.$showModal({
							    title:'温馨提示',
							    concent:'您还未填写您的学校',
							    confirmVal:'去填写',
								// delCancel:true,
							    cancelVal:'拒绝',
							}).then(res=>{
								uni.navigateTo({
									url:'/pages/mine/editinfo/editinfo'
								})
							}).catch(()=>{
							   //拒绝了~~		   
							})
						}
					}
					if(this.nav_index==5){
						if(this.userInfo.work_experience){
							this.getRandomFriendsfun();
						}else{
							this.$showModal({
							    title:'温馨提示',
							    concent:'您还未填写您的公司',
							    confirmVal:'去填写',
								// delCancel:true,
							    cancelVal:'拒绝',
							}).then(res=>{
								uni.navigateTo({
									url:'/pages/mine/editinfo/editinfo'
								})
							}).catch(()=>{
							   //拒绝了~~		   
							})
						}
					}
					// if(this.county_id){//有城市id 不用
					// 	console.info("11");
					// 	this.getRandomFriendsfun();
					// }else{
					// 	console.info("22");
					// 	this.getlatandlng_one();
					// }
				}
			},
			getweixin() {
				// #ifdef MP-WEIXIN
				wx.getUserProfile({ //获取用户信息
					lang: 'zh_CN',
					desc: '用于完善会员资料',
					success: (res) => {
						wx.login({
							provider: 'weixin',
							success: (loginRes)=> {
								//loginRes中有code，拿着code再请求自己服务器以获取openid
								console.log('1111111111111',loginRes);
								authorWechat({
									code:loginRes.code
								}).then((res)=>{
									
								})
							}
						});
					}
				})	
				// #endif
			},
			
			async getUserinfofun() {
				let res  = await getUserinfo({

				})
				if(res.code==1){
					console.log(res.data.userinfo)
					this.userInfo = res.data.userinfo;
					uni.setStorageSync("u_userInfo", res.data.userinfo);					
					this.area_obj = {
						province_id:res.data.userinfo.province_id,
						city_id:res.data.userinfo.city_id,
						area_id:res.data.userinfo.area_id,
						town_id:res.data.userinfo.town_id,
						village_id:res.data.userinfo.village_id,
					};
					setTimeout(()=>{
						this.$refs.xkyguidestep.getinit();//提示引导
					},500)
				}
				
			},
			//获取推荐好友
			getRandomFriendsfun(){
				getRandomFriends({
					type:this.nav_index,
					surname_id:this.userInfo.surname_id,//姓氏
					...this.area_obj,
				}).then(res=>{
					if(res.code==1){						
						let friend_list = res.data.list;
						for(let j=0;j<friend_list.length;j++){
							friend_list[j].rntitle =  '加好友'
							var val = friend_list[j].id;
							for(var key in this.friends){
								for(var i=0;i<this.friends[key].length;i++){
									if(val==this.friends[key][i].friend_id){
										friend_list[j].rntitle = '发消息';
										break;
									}else{
										friend_list[j].rntitle =  '加好友'
									}
								}
							}
							
							this.friend_list.push(friend_list[j]);
						}
						
						
						// this.friend_list.push(friend_list);
					}
				})
			},
			//加好友
			toCall(item){
				if(this.loginAuct()){
					uni.navigateTo({
						url:`/pagesim/center/info?id=${item.id}`
					})
				}
			},
			//获取定位
			getlatandlng_one(){
				let istongyilat = uni.getStorageSync("istongyilat");
				if(istongyilat==1){
					this.getlatandlng();
				}else if(istongyilat==2){
					console.info("被拒绝了 不再询问！！");
				}
				else{
					// delCancel: true,
					if(uni.getSystemInfoSync().platform=='ios'){
						this.$showModal({
						    title:'温馨提示',
						    concent:'系统将获取您的位置信息,用于获取你所在城市的好友推荐',
						    confirmVal:'继续',
							delCancel:true,
						    // cancelVal:'拒绝',
						}).then(res=>{
							uni.setStorageSync("istongyilat",1)
						    this.getlatandlng();
						}).catch(()=>{
						   //拒绝了~~
						   //拒绝了
						   uni.setStorageSync("istongyilat",2);
						})
					}else{
						this.$showModal({
						    title:'温馨提示',
						    concent:'系统将获取您的位置信息,用于获取你所在城市的好友推荐 是否继续？',
						    confirmVal:'继续',
						    cancelVal:'拒绝',
						}).then(res=>{
							uni.setStorageSync("istongyilat",1)
						    this.getlatandlng();
						}).catch(()=>{
						   //拒绝了~~
						   //拒绝了
						   uni.setStorageSync("istongyilat",2);
						})
					}
				}
			},
			getlatandlng(){
				// #ifndef MP-WEIXIN
				uni.getLocation({
					// type: 'gcj02', //返回可以用于uni.openLocation的经纬度
					success: res => {
						this.latitude = res.latitude;
						this.longitude = res.longitude;
						this.lk_reverse_fun({lon:res.longitude,lat:res.latitude});
					},
					fail: err => {
						console.info("err",err);
					}
				})
				// #endif
			
				// #ifdef MP-WEIXIN
				uni.getFuzzyLocation({
					type: 'gcj02', //返回可以用于uni.openLocation的经纬度
					success: res => {
						this.latitude = res.latitude;
						this.longitude = res.longitude;
						this.lk_reverse_fun({lon:res.longitude,lat:res.latitude});
					},
					fail: err => {
						console.info("err",err);
					}
				})
				// #endif
				
			},
			//逆解析
			lk_reverse_fun(res){
				lk_reverse({
					lon:res.lon,
					lat:res.lat,
				}).then((success)=>{
					console.info('success',success);
					let result = success.result[0];
					console.info("province_id",result.properties.province_id,typeof(result.properties.province_id));
					this.province_id = result.properties.province_id;
					this.county_id = result.properties.county_id;
					uni.getStorageSync("province_id",this.province_id);
					uni.getStorageSync("county_id",this.county_id);
					// this.district = result.properties.county;
					// let county_id = parseInt(result.properties.county_id);
					// this.city_id = county_id-(county_id%100);														
				})
			},
		}
	}
</script>

<style lang="scss">
	.menu_u_item_num1{
		// height: ;
		font-size: 18rpx;
		font-weight: 600;
	}
	@import "./user.scss";
</style> 